﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine.UI;
using UnityEngine.SceneManagement;
using UnityEngine;

public class Shop : MonoBehaviour {
    private GameID theGameId;
    private string NowGamer;

    public float getMoney()
    {
        return PlayerPrefs.GetFloat(NowGamer + "Money");
    }

    public void setMoney(float money)
    {
        PlayerPrefs.SetFloat(NowGamer + "Money", money);
    }

    public void setMusic(int no)
    {
        PlayerPrefs.SetInt(NowGamer + "Music", no);
    }

    public int getMusic()
    {
        return PlayerPrefs.GetInt(NowGamer + "Music");
    }

    public int getShop()
    {
        return PlayerPrefs.GetInt(NowGamer + "Shop");
    }

    public void setShop(int Shop)
    {
        PlayerPrefs.SetInt(NowGamer + "Shop", Shop);
    }

    public Text MoneyText;
    public AudioClip[] audios;


    void Awake()
    {
        theGameId = GameObject.Find("Main Camera").GetComponent<GameID>();
        NowGamer = theGameId.nowGamer;
        Debug.Log(theGameId.nowGamer);
        MoneyText.text = "Money: "+getMoney().ToString();
    }

    public void ReturnMain()
    {
        SceneManager.LoadScene(1);
    }

    void Update()
    {
        MoneyText.text = "Money: " + getMoney().ToString();
    }

    public void TryMusic(int number)
    {
        this.GetComponent<AudioSource>().clip = audios[number];
        this.GetComponent<AudioSource>().Play();
    }
}
